<template>
	<view class="uni-tab-bar">
		<scroll-view scroll-x="true" class="uni-swiper-tab">
			<block v-for="(tab,index) in tabBars" :key="tab.id">
				<view class="swiper-tab-list" :class="{'active':index==tabIndex}" @tap="tabTap(index,tab.type)" :style="scrollWidth">
					{{tab.name}} {{tab.num?tab.num:""}}
					<view class="swiper-tab-line main-bj"></view>
				</view>
				
			</block>
			
		</scroll-view>
	</view>
</template>

<script>
	export default {
		props:{
			tabBars:Array,
			tabIndex:Number,
			scrollWidth:{
				type:String,
				default:""
			}
		},
		methods:{
			//tabbar点击切换事件
			tabTap(index,type){
				this.$emit('tabTap',index,type) //子组件传值给父组件
			}
		}
	}
</script>

<style scoped>
	.swiper-tab-list{
		font-weight: bold;
		font-size: 26rpx;
		width: initial;
		padding: 0 25rpx;
		box-sizing: border-box;
	}
	.uni-tab-bar .active {
		color: #000000;
	}
	.uni-swiper-tab{
		border-bottom: 0;
	}
	.active .swiper-tab-line{
		height: 8rpx;
		width: 65rpx;
		margin-top: -20rpx;
		margin-left: auto;
		margin-right: auto;
	}
</style>